package com.fjnu.entity;

import java.util.Date;

public class User {
    private String userId;
    private String username;
    private String password;
    private String salt;
    private String nickname;
    private String email;
    private String phone;
    // 关键：Integer类型字段默认初始化（避免null）
    private Integer sex = 0; // 0-未知
    private Integer age = 0;
    private String img;
    private Integer status = 1; // 1-正常
    // 时间字段默认初始化（避免null）
    private Date createTime = new Date();
    private Date updateTime = new Date();
    private Date lastLoginTime;


    // 全参构造器（可选，方便测试）
    public User(String userId, String username, String password, String salt) {
        this.userId = userId;
        this.username = username;
        this.password = password;
        this.salt = salt;
        this.sex = 0;
        this.age = 0;
        this.status = 1;
        this.createTime = new Date();
        this.updateTime = new Date();
    }

    // 无参构造器（必须，Spring 依赖注入需要）
    public User() {
        this.sex = 0;
        this.age = 0;
        this.status = 1;
        this.createTime = new Date();
        this.updateTime = new Date();
    }

    // Getter 和 Setter 方法（完整实现）
    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Integer getSex() {
        return sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex; // 即使外部传null，实体类默认已设为0，不会覆盖
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getImg() {
        return img;
    }

    public void setImg(String img) {
        this.img = img;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Date getLastLoginTime() {
        return lastLoginTime;
    }

    public void setLastLoginTime(Date lastLoginTime) {
        this.lastLoginTime = lastLoginTime;
    }
}